package com.pluginsacceptor.plugin.formula.MathsTrigo;

import javax.swing.JMenu;
import javax.swing.JMenuItem;

import com.pluginsacceptor.plugin.formula.MathsTrigo.support.DataListener;
import com.pluginsacceptor.plugin.formula.MathsTrigo.support.DataSender;
/**
 * @author VadymPivak
 * The class MathsTrigMenu to build a menu and add the listener for each if items
 */
public class MathsTrigMenu extends JMenu {

	/** */
    private final DataListener dataListener;

    /** */
    private final DataSender dataSender;

    /**
     *
     */
    private static final long serialVersionUID = -3110316243457377854L;

    public MathsTrigMenu(final DataListener dataListener, final DataSender dataSender) {
		super("Maths&Trigo");
		this.dataListener = dataListener;
	    this.dataSender = dataSender;
		this.addItems();
		this.addListeners();
}

	JMenuItem somme;
	JMenuItem produit;
	JMenuItem soustraction;
	JMenuItem division;
	JMenuItem cos;
	JMenuItem sin;
	JMenuItem tan;
	JMenuItem acos;
	JMenuItem asin;
	JMenuItem atan;
	JMenuItem modulo;
	JMenuItem racine;
	JMenuItem puissance;
	JMenuItem exp;
	JMenuItem log;
	JMenuItem log10;
	JMenuItem aleatoire;


	private void addListeners() {
	    somme.addActionListener(new SommeListenercalcul(dataListener, dataSender));
		produit.addActionListener(new ProduitListener());
		soustraction.addActionListener(new SoustractionListener());
		division.addActionListener(new DivisionListener());
		cos.addActionListener(new CosListener());
		sin.addActionListener(new SinListener());
		tan.addActionListener(new TanListerner());
		acos.addActionListener(new AcosListener());
		asin.addActionListener(new AsinListener());
		atan.addActionListener(new AtanListener());
		modulo.addActionListener(new ModuloListener());
		exp.addActionListener(new ExpListener());
		log.addActionListener(new LogListener());
		log10.addActionListener(new Log10Listener());
		puissance.addActionListener(new PuissanceListener());
		racine.addActionListener(new RacineListener());
		aleatoire.addActionListener(new AleatoireListener());
	}

	private void addItems() {
		somme = new JMenuItem("Somme");
		add(somme);
		produit = new JMenuItem("Produit");
		add(produit);
		soustraction = new JMenuItem("Soustraction");
		add(soustraction);
		division = new JMenuItem("Division");
		add(division);
		cos = new JMenuItem("Cos");
		add(cos);
		sin = new JMenuItem("Sin");
		add(sin);
		tan = new JMenuItem("Tan");
		add(tan);
		acos = new JMenuItem("acos");
		add(acos);
		asin = new JMenuItem("asin");
		add(asin);
		atan = new JMenuItem("atan");
		add(atan);
		modulo = new JMenuItem("Modulo");
		add(modulo);
		racine = new JMenuItem("racine");
		add(racine);
		puissance = new JMenuItem("puissance");
		add(puissance);
		exp = new JMenuItem("Exp");
		add(exp);
		log = new JMenuItem("log");
		add(log);
		log10 = new JMenuItem("log10");
		add(log10);
		aleatoire = new JMenuItem("Alatoire");
		add(aleatoire);
	}
}